import { BaseWindow } from "../../../../component/window/BaseWindow";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { DeployPanelItem } from "../deploy/DeployPanelItem";
import { NumberSetStepper } from "./NumberSetStepper";
import { ItemData } from "../../../resource/info/ItemData";
import { PopupManager } from "../../../manager/PopupManager";
import { EItemUpdateContinue } from "../../../../../Message/Game/EItemUpdateContinue";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { _EItemUpdateContinueNo } from "../../../../../EItemUpdateContinue/_EItemUpdateContinueNo";
type int = number;
//class AutoComposeJewelPanel
    
    export  class AutoComposeJewelPanel extends BaseWindow
    {
        constructor()
        {
            super();
            this.setSize(280, 200);
            this.titleHeight = 24;
            this.title = Language.getString(60296);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(13, 35, 250, 118, this);
            ObjCreate.createLabel(Language.getString(60297), 100, 76, 90, 20, flash.text.TextFormatAlign.LEFT, this, false, 11726847);
            ObjCreate.createLabel(Language.getString(60298), 207, 76, 90, 20, flash.text.TextFormatAlign.LEFT, this, false, 11726847);
            this._imageItem = new DeployPanelItem(0);
            this._imageItem.x = 43;
            this._imageItem.y = 66;
            this._imageItem.label = "";
            this.addChild(this._imageItem);
            this._numStepper = new NumberSetStepper();
            this._numStepper.x = 135;
            this._numStepper.y = 75;
            this._numStepper.min = 1;
            this._numStepper.max = 99;
            this.addChild(this._numStepper);
            this._isGoOnCb = ObjCreate.createCheckBox(Language.getString(60299), 44, 125, 165, 20, this);
            this._btnOK = ObjCreate.createGButton(Language.getString(69901), 55, 160, 70, 28, this);
            this._btnCancel = ObjCreate.createGButton(Language.getString(69902), 162, 160, 70, 28, this);
            this._btnOK.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._btnCancel.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            _closeBtn.configEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        public set imageItemData(arg1: ItemData)
        {
            this._imageItem.itemData = arg1;
            return;
        }

        public setAmount(arg1: int): void
        {
            if (arg1 <= 0) 
            {
                arg1 = 1;
            }
            this._numStepper.max = arg1;
            this._numStepper.value = arg1;
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=arg1.target;
            switch (loc2) 
            {
                case this._btnOK:
                {
                    PopupManager.removePopup(this);
                    loc1 = new Object();
                    loc1.amount = this._numStepper.value;
                    loc1.flag = this._isGoOnCb.selected ? EItemUpdateContinue._EItemUpdateContinueYes : _EItemUpdateContinueNo;
                    this.dispatchEvent(new DataEvent(EventName.Equipment_OnAutoUpdate, loc1));
                    break;
                }
                case _closeBtn: case this._btnCancel:
                {
                    PopupManager.removePopup(this);
                    break;
                }
            }
            return;
        }

        protected /* override */ updateSize(): void
        {
            super.updateSize();
            _windowCenter.height = 128;
            return;
        }

        /* internal */ /* var */_imageItem: DeployPanelItem;

        /* internal */ /* var */_numStepper: NumberSetStepper;

        /* internal */ /* var */_isGoOnCb: GCheckBox;

        /* internal */ /* var */_btnOK: GButton;

        /* internal */ /* var */_btnCancel: GButton;
    }
